<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="d1">这是div</div>
<input type="text">
<input type="button" value="按钮" onclick="f()">
<script>
  function f(){
    //通过id找到元素对象
    let d = document.getElementById("d1");
    //获取和修改元素的文本内容
    console.log(d.innerText);
    // d.innerText="内容被改掉了"

    //通过选择器找到页面的元素对象
    let i = document.querySelector("input");
    //修改元素的value属性
    // i.value = "今天有点热";
    d.innerText = i.value;
  }



</script>
</body>
</html>